<template>
  <div>
    <el-dialog
      title="日报"
      :visible.sync="shows"
      width="60%"
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form">
        <el-form-item prop="projectCode" label="编号" label-width="80px">
          <el-input
            v-model="form.projectCode"
            :disabled="true"
            style="width: 80%"
          ></el-input>
        </el-form-item>
        <el-form-item prop="content" label="内容" label-width="80px">
          <el-input
            v-model="form.content"
            style="width: 80%"
            type="textarea"
          ></el-input>
        </el-form-item>
        <el-form-item prop="date" label="日期" label-width="80px">
          <!-- <el-input v-model="form.date" style="width: 80%"></el-input> -->
          <template slot-scope="scope">
            <el-date-picker
              v-model="form.date"
              style="width: 80%"
              placeholder="选择日期时间"
              type="date"
              value-format="yyyy-MM-dd"
              format="yyyy-MM-dd"
              size="small"
            ></el-date-picker>
          </template>
        </el-form-item>
        <el-form-item prop="name" label="填报人" label-width="80px">
          <el-input
            v-model="form.name"
            :disabled="true"
            style="width: 80%"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: ["shows", "projectCode"],
  data() {
    return {
      form: {
        projectCode: "",
        content: "",
        date: "",
        name: "",
      },
    };
  },
  watch: {
    projectCode(newV) {
      console.log(newV, "newVB");
      this.form.projectCode = newV;
      this.form.name = this.$store.state.user.name;
    },
  },
  methods: {
    handleClose() {
      this.$emit("closes", true);
      this.$refs.form.resetFields();
    },
    submit() {
      this.$http.post("/postmddetail", this.form).then((res) => {
        if (res.code == 200) {
          this.$refs.form.resetFields();
          this.handleClose();
          this.$nextTick(() => {
            this.$emit("refresh", true);
          });
        }
      });
    },
  },
};
</script>

<style>
</style>